package com.comleader.operator.service.strategy;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.comleader.operator.common.constant.GlobalVariables;
import com.comleader.operator.common.enums.OperatorInspectTypeEnum;
import com.comleader.operator.pojo.entity.InspectRecordEntity;
import com.comleader.operator.validate.ValidateRule;

/**
 * @Dscription 上报数据策略接口
 * @Author 连新景
 * @Date 2024/02/26 17:55
 */
public interface InspectStartegy {

    void inspect(InspectRecordEntity inspectRecord, String importFilePath);

    /**
     * @Description 获取启用的校验规则列表
     * @Auhtor 连新景
     * @Date 2024/08/08 9:29
     * @param allRuleList
     * @param inspectTypeEnum
     * @return java.util.List<com.comleader.operator.validate.ValidateRule<T>>
     */
    default <T> List<ValidateRule<T>> listEnableValidateRule(List<ValidateRule<T>> allRuleList, OperatorInspectTypeEnum inspectTypeEnum) {
        Map<Integer, List<String>> typeCodeMap = GlobalVariables.getTypeCodeMap();
        List<String> list = typeCodeMap.get(inspectTypeEnum.getType());
        List<ValidateRule<T>> enableRuleList =
            allRuleList.stream().filter(validateRule -> list.contains(validateRule.getRuleCode())).collect(Collectors.toList());
        return enableRuleList;
    }
}
